package com.xbongbong.paas.help.factory;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.OperationsPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.businessrule.pojo.BusinessRuleInfoPojo;

import java.util.List;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2020/3/3 19:40
 * @since v1.0
 */
public interface OperatorFieldHandler {

    /**
     * 字段类型
     * @return 字段类型
     */
    List<Integer> fieldType();

    /**
     * 处理本表单字段
     * @param paasFormDataEntity 主要用来取data外的数据
     * @param data 主要是用来放子表单的数据
     * @param fieldAttrEntity 字段
     * @param businessRuleInfoPojo 容器
     * @return
     * @throws XbbException
     */
    Object handlerThisFormField(PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity,
                                BusinessRuleInfoPojo businessRuleInfoPojo) throws XbbException;

    /**
     * 处理目标表单
     * @param paasFormDataEntity
     * @param data
     * @param fieldAttrEntity
     * @param targetField
     * @param businessRuleInfoPojo
     * @param operation
     * @return
     * @throws XbbException
     */
    Object handlerTargetFormField(PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity, FieldAttrEntity targetField,
                                  BusinessRuleInfoPojo businessRuleInfoPojo, OperationsPojo operation) throws XbbException;

    /**
     * 处理固定值
     * @param targetField
     * @param businessRuleInfoPojo
     * @param operation
     * @return
     * @throws XbbException
     */
    Object handlerFixedValue(FieldAttrEntity targetField,
                             BusinessRuleInfoPojo businessRuleInfoPojo, OperationsPojo operation) throws XbbException;
}
